All Questions
Tagged with time-limit-exceededdynamic-programming
38 questions
6votes
1answer
347views
Codeforces: D2. Counting Is Fun (Hard Version)
The code works okay for the following problem. Problem An array ๐ of ๐ non-negative integers is said to be good if all the elements of ๐ can be made equal to 0 using the following operation some (...
4votes
2answers
131views
Find largest sum not involving consecutive values
There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and ...
2votes
1answer
194views
k-dice Ways to get a target value
I'm trying to solve the following problem: You have a k-dice. A k-dice is a dice which have k-faces and each face have value written from 1 to k. Eg. A 6-dice is the normal dice we use while playing ...
2votes
2answers
166views
Making my DP algorithm faster - longest palindromic substring
The following code is my solution to a LeetCode question - find the longest palindromic substring. My code is 100% correct, it passed once but it took too long, and in most of the reruns I hit a "...
3votes
1answer
271views
Longest Palindromic Substring | Python Code Giving TLE
Problem Statement Given a string s , return the longest palindromic substring in s. Constraints ...
2votes
2answers
2kviews
HackerRank: Sam and substrings | How can dynamic programming be used in my code?
Given a number as a string, no leading zeros, determine the sum of all integer values of substrings of the string. Given an integer as a string, sum all of its substrings cast as integers. As the ...
4votes
5answers
823views
Find maximum value of recursively-defined "fusc" function
I've been trying this question from SPOJ, which asks for the user to enter a number n, and they will receive a maximum fusc value that lies in between 0 to ...
1vote
1answer
239views
Target Sum array using Dynamic Programming
I'm learning Dynamic Programming and trying to solve this Target Sum array problem. I've to find an array of integers that sums to a given target sum using the integers of given input array. I've used ...
3votes
1answer
3kviews
Recursive solution of ordered Coin Combinations II (CSES)
Question Link Consider a money system consisting of n coins. Each coin has a positive integer value. Your task is to calculate the number of distinct ordered ways you can produce a money sum x using ...
1vote
2answers
343views
Leetcode 377. Combination Sum IV Javascript Memoization attempt
Problem Statement ...
0votes
3answers
480views
Calculate sum of a substring
I try to solve some old Codeforces questions. The problem is; Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q ...
3votes
0answers
135views
C++ - Longest Common Subsequence
Link to the Problem Here is my code to compute the length of the longest common subsequence of two integer arrays arr[] and brr[]...
1vote
2answers
247views
Recursive brute-force approach to maximum points you can obtain from cards
I came across this question on Leetcode. The question description is as follows: There are several cards arranged in a row, and each card has an associated number of points. The points are given in ...
2votes
1answer
2kviews
Maximum sum combination
I am trying to solve this question: https://www.codechef.com/problems/TADELIVE Andy and Bob are the only two delivery men of Pizza-chef store. Today, the store received N orders. It's known that ...
2votes
1answer
167views
How do I optimize memoization in order to find longest palindromic substring?
I want to find the longest palindromic substring using dynamic programming in Python3. The strings can be as large as this string. I have seen other questions on this problem that successfully solve ...